#include<bits/stdc++.h>
using namespace std;
const double e=1e-5;
#define REP(i,a,n) for(int i=(a);i<n;i++)
struct node{
	double l,r;
	int flag;
}s[100100];
int Abs(double g){
	return g>=0? g:-g;
}
int Max(double g,double h){
	return g>=h? g:h;
}
int cnt;
double p[100100],d[100100],v[100100],a[100100];
bool cmp(node f,node g){
	if(f.l!=g.l)return f.l<g.l;
	return f.r<g.r;
}
int main(){
	freopen("detect.in","r",stdin);
	freopen("detect.out","w",stdout);
	int t;
	scanf("%d",&t);
	while(t--){
		cnt=0;
		int n,m;
		double l,k;
		scanf("%d%d%lf%lf",&n,&m,&l,&k);
		int ans=0;
		REP(i,0,n){
			scanf("%lf%lf%lf",&d[i],&v[i],&a[i]);
		}
		REP(i,0,m){
			scanf("%lf",&p[i]);
		}
		double kk=-2;
		REP(i,0,n){
			if(!a[i]){
				if(v[i]>k&&d[i]<=p[m-1]){
					ans++;
					kk=Max(kk,d[i]-1);
				}
			}
			if(a[i]>0){
				if(v[i]>k){
					if(d[i]<=p[m-1]){
						ans++;
						kk=Max(kk,d[i]-1);
						continue;
					}
				}
				else{
					double q=(k*k-v[i]*v[i])/a[i]/2;
					if(d[i]+q<p[m-1]){
						ans++;
						kk=max(kk,d[i]+q);
					}
				}
			}
			if(a[i]<0){
				if(v[i]>k){
					double q=(k*k-v[i]*v[i])/a[i]/2;
					s[cnt++]={d[i],min(l+1,d[i]+q),1};
				}
			}
		}
		if(kk>-2){
			ans--;
			REP(i,0,m){
				if(p[i]>kk){
					s[cnt++]={p[i],l+1,1};
					break;
				}
			}
		}
		sort(s,s+cnt,cmp);
		int g=0;
		REP(i,0,cnt){
			while(s[i].l-p[g]>e&&g<m)g++;
			if(s[i].l-p[g]>e){
				break;
			}
			if(s[i].r-p[g]>e){
				ans++;
				s[i].flag=0;
			}
		}
		cout<<ans<<" ";
		g=m;
		p[g]=2*l;
		int num=0;
		for(int i=cnt-1;i>=0;i--){
			if(s[i].flag)continue;
			if(p[g]-s[i].r>-e){
				num++;
				while(p[g-1]-s[i].l>-e)g--;
			}
		}
		cout<<m-num<<endl;
	}
	return 0;
}
